{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sympy as sp\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from typing import Dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "sp.init_printing(use_unicode=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 待求解信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAASCAYAAABSO15qAAAABHNCSVQICAgIfAhkiAAAAJ5JREFUOI29kzEKwzAMRV+Kh0CPUkiG5lC9QxdvPUHXniOHSKb0Fpm7eGkHC2qMbVQb+kHIYPlJ/tidtZYWHYL1Drx/iAuAkcNH4B7BDXAFHHBLNJ9DwAuwUcEogC2xl7xCrEnyWqgpAs6Sl1ZA1QQGGPAGPmsAJ6DHG+hqACoDSwCVgRpA1QRqA3MAtYE5gHp8+P6FUA8JlUov8T+AD8SeJPgHYf62AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle T$"
      ],
      "text/plain": [
       "T"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADcAAAAVCAYAAADiv3Z7AAAABHNCSVQICAgIfAhkiAAAAxlJREFUWIXd11uIVlUUB/CfaaRNoVhg0EWNyEsXnMYiIupBK+qpy1NRJvXQkw1ELxXRx5BdHkKNICgo66kMu0AvEhFNV8opu2lQJGU1ZFEkSpNR08Pap9lz3Oeb75MZHPrDYX3f+u/b2v919tpnRqvV8n/FUUd6ATU8i73o6aJPH0Zxa52YquBa2Nxln5W4EQ/hQIG/QwRxQ80/hJdxP47LickMbmEb7tQO5noA+/B4A39eskMF7kGchNtz52QFtxifYyPmZv7ZuBdf4KI2/c/EamzBHw1t+rAfXxW4D/AlbsPMylkP7m4h/TWFARYm7sUCtxvLcDx2YhXOFQH34gK83bBouAUz8HyBezjNu1Sk3d/p/6hI4wrP4TSxSWBWbaB20q9M9uOGBX4vXuprhQIz0Y9HG9rnWJ0W/X6BG8IzuBnv4rWMezP7/U6yl2EbhwbXh1/wXWGSiYI7RRwkV+I9ceL141LcI9KmhB6swC7lg2QL5ongNuPJhnE+TPaSypGn5XwsUlaNseA+KnCLs8Utx+v4FGfhE/FOXNww7slC5eEGnrGMatpY+B0jIjUxXrlqgO1tJtiLHwvcbpyNb2v+EQzgafzQMO4Jyf7WtOo091/4rE0b+BULqj+5cn3JlpQ7XShbUq1CPbAce/BPA1edjrMb+Fk4RxxUf7aZA+Zk441TrjfZUgBXJdsuLXK0OmxHZANjCtaxXATebmMJoeaJLPrPUWGpkL6uwDGifuhggsPBMH7GkgZ+RbITbewSUU52VI48uIM4WhTUCj14SrxPnUxwOBjFIE7EGQW+UnTfBONcmOwblSNPy204X9SOl0TBXCVOvWEci2+6XHin2IrrcAW+rnHVGbBebPIBceN5odbuclErX6kcuXLrRcEdxVqR6wO4XtzbdiRuKrAVP2FNgRvEOhHUOtxnLFUrzMXVeFUcXhiv3Igouv2FCab60+ggNonLc69D0/+x9DRhjTh0Hsmd0+l7boO4GQ102W8O7hLqv5UT0ym4EdwkLhHdfKwuwhO4s07U75ZHGoPp6Qa7NNTV6aTcpONfAnugwRl5XIYAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\operatorname{u*}{\\left(t \\right)}$"
      ],
      "text/plain": [
       "u*(t)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADcAAAAXCAYAAACvd9dwAAAABHNCSVQICAgIfAhkiAAAA0tJREFUWIXd2GuIpmMYB/Df7I7stqPZrCKHtVtymF3s7kja5JBhkw+EL8QqihKm5Isk0+b4QdiUHMpSxGqEUEuSWawwznZl1WBps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ystyle \\operatorname{p*}{\\left(t \\right)}$"
      ],
      "text/plain": [
       "p*(t)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADYAAAAVCAYAAAANfR1FAAAABHNCSVQICAgIfAhkiAAAAyBJREFUWIXd12+on2MYB/DP2YazhimSMn8m+bMz2s4kIV4Y8k54MzHFi73iICUt+ZF/e4GRUqTGK6ZTFC8kyWGj2cFmM6GOP6tlisjJGc3x4rqfzn2e3c+z3y9n7eRbv67fc33v53qu676vP8/T1+l0/B8x53A7kOFl7MWCHu5ZgUncVicORWAdbOjxngtwEx7HeIG/WwRwY00/itfxMI7OiZkK7LQW7pQunvMofsdzDfxgkqMF7jGchDty5UwEthg7sB4LM30/7sdOXNxy/1lYiY34s2HNCvyBbwrcFnyFNZhbKfPA7hPHfXuD8TOwLxnqy/RjOBfH4EtcgfNFsMtxIT5sDItbk71XC9y65NM5ItX2p+tJkboVXsGpYoPAvIzcluTSBgfW4UjclQzn2C0K+Dqx83MxhGdaAqqwMjn8cYEbxUu4BZvxTsa9n/3flOSVeJvpgW1PcqDwgEtwQ3J6U4FfJJrGNfhIdLYhXI61IlVKWIBl2KXcNDbiOBHYBrzQYOeTJC+rFHkq7sYvDgysD0+KNLy3YHRx5tgSvCs2aUBkwRZc2uDQyeJ09zTwTDWOz1rW/IYJkY44sHlsFzu0KNOtEnWyHt8VjI6J9B1KD6gwgYdEgJsbHDo+yV9bnB7E3/iiZQ1xKCdUF/XAqjqrTq1ftOK9STbh+xbuR/zTwFVdsL+Bn4fzRFPa1/IMmJ/Zm1ZjTNXZUlGEd4oZtUbMmW7Q6XIdsWFMnVwdS0TQnx7EzhyRaWO5IkfeGU8UI2AHXuzB2V6wBz/j7AZ+WZJt9SXd34fPK0U9sJ2i9Q7gQRwrXmf29+Zv15jEiKiNMwt8dZIHy5aLknyvUtRTcQJfiwE7iLdMnx2HAsO4Hlfj2xpXvUI9IrJoXGz+a7V1V4nNf6NSlF6ptuEosZv3/Fevu8AwfsLqAjci3oTGk3zAVHpWWIhr8aZoVCgHtkrk6xGaB+tM4i88LUbK8gL/rKih/uTX2hq/OnFP5MrZ8j32FH4Qc68XzBcNbhgf5MRsCWwCN2Or3j40T8fzCiVTbx6HEyPp1wt2aZibs+XEZhz/AhKEoMYZoSWnAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\operatorname{v*}{\\left(t \\right)}$"
      ],
      "text/plain": [
       "v*(t)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "T = sp.var('T')\n",
    "t = sp.var('t')\n",
    "u_best = sp.Function('u*')(t)\n",
    "p_best = sp.Function('p*')(t)\n",
    "v_best = sp.Function('v*')(t)\n",
    "display(T)\n",
    "display(u_best)\n",
    "display(p_best)\n",
    "display(v_best)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 已知信息\n",
    "1. System equation\n",
    "2. Cost Function\n",
    "3. Boundary Values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "System Equation：\n"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}\\frac{d}{d t} p{\\left(t \\right)}\\\\\\frac{d}{d t} v{\\left(t \\right)}\\end{matrix}\\right] = \\left[\\begin{matrix}v{\\left(t \\right)}\\\\u{\\left(t \\right)}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡d       ⎤         \n",
       "⎢──(p(t))⎥         \n",
       "⎢dt      ⎥   ⎡v(t)⎤\n",
       "⎢        ⎥ = ⎢    ⎥\n",
       "⎢d       ⎥   ⎣u(t)⎦\n",
       "⎢──(v(t))⎥         \n",
       "⎣dt      ⎦         "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print('System Equation：')\n",
    "p = sp.Function('p')(t)\n",
    "v = sp.Function('v')(t)\n",
    "u = sp.Function('u')(t)\n",
    "se = sp.Eq(sp.Matrix([sp.diff(p, (t, 1)), sp.diff(v, (t, 1))]), sp.Matrix([v, u]))\n",
    "display(se)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost Function: \n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGMAAAArCAYAAABsMDaUAAAABHNCSVQICAgIfAhkiAAABepJREFUeJztm3uIFVUcxz9rZruZGK6IKZoslSZJelclXJLKR2BERVT0UKMHUWBF9MAI27XUrOxFbVEQZkRprRVJoSXRhlHp1vYOLEPL1E1NTcvUxf74numOZ+fMmbt37rqu84XLmTm/mfM7M7/ze565ZbW1tWToHOiW4liTgYOe35Up8uty6J7iWB8DJ4XOm4BXgUdDfdtS5NflkKYw/jE/gEpgALAK2Jwijy6NNM1UGDnTNpVo/C6JUgmjGpmkDSUav0uiEGGUAcckvDYHfFH4dI5uJBFGOTAP2A7sBB7GL5QcmYkqGEkc+AvANaHzu4AdwFzH9b2BKjLNKBg+zegHXG2ObwUuN8c3x9yTQyYtE0aB8AljJHqxAK8AS4F3gZXA8Y57csicrUtjggYzgdXALuAP4B3gjBTH7xTwCaOvafcin9EKXABcC/ztuGcBcCLKuNPCOUA9MA44DzgAfAD0SZHHYYfPZ/Qy7a5ST8SD863zqUj7apCWdAn4NOME0+4u9UQKRC809+0x1ywCWoCeCcesRtp8fXFT+x+DzXhLk97gE0agGX+1d0YlwhNAM/Cpgz4aRYAPAXss2h3oJV1l9TcBbwEPkl+ExSCoQtiBjIv/EakZjwDjgcuQD4vCXGRan42gxZVq5gH9UeRYLFx8nPyPNM1YAEwDJgA/Oa45DZgILCFfuAyjGi2utRG0z4EfgZtIXm1wodq0tmY4+R8OzbgXqeklEbSTcdvZp5DpORf4Pmb861A4vtjqn2/GHoaeq5X8Pks4qX0N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t5Avc2dICDvP2MGhGy1JYYejZRF9GTwo9iv0rShBsrWgH221JYMHxQpjHwplJ1n9k9BuVoYCkMY/lx4DXkab+atQwW8A8FwKYx9VSEMYi1ER7D70n75vUSRmlwMyeJDWf/rqySeLGdqJUv2NLEM7kAmjEyETRifCf9OFWXGCvkcyAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\int\\limits_{0}^{T} u^{2}{\\left(t \\right)}\\, dt$"
      ],
      "text/plain": [
       "T         \n",
       "⌠         \n",
       "⎮  2      \n",
       "⎮ u (t) dt\n",
       "⌡         \n",
       "0         "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print('Cost Function: ')\n",
    "Jk = sp.integrate(u**2, (t, 0, T))\n",
    "display(Jk)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Boundary Values\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABcAAAATCAYAAAB7u5a2AAAABHNCSVQICAgIfAhkiAAAAZRJREFUOI3V1D9IVlEYx/GPZhooFBVhDtGchZS4CEENb1ENLkE0NAVGEQYOQeDwTtEkWCBFDYEohBTUUORqIQgR/YHCBvsHIpTgJoLpcM6Fw+324utLgz+4/DjPved7zn2e55y6crnsf6k+N+7GKm7jPCaxiCVM43gt8CPRSxjBAu7FRbrwHPtqhbfhGHpwPS52B9vQVyv8Kl7l3j2IfmAj8KY48QdGC779HX1rEruCWaEmb3D0X/BDceJL/CmA74/+Pfo5DOEmDuM1XkhqksKzlHwtAMOZ6BPR+/EQ9/FJqMUcLleC7ygA70QvfuIpGtGZLJRpQmjnv+Cd0c+iOYm3YAy7cE3I725swXwOPo/WbNCQ+EG8w3a8xzOhyD1Ca97AkxxsNTeuS2PZztuFHp7CCczgIi4I+TyJWwnkF1bSXUbtSf8m23mW77f4glMqa1lovRLGk3gJjyvB16tB4YqYFtrwkpC+u0XwFXyoAv5IKPIA9uIjTuNbCq9HBz4LnVCNhuNTqAbhNLZUCV2X8hfX5oGvAW7WTgS4YsmsAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle p_{0}$"
      ],
      "text/plain": [
       "p₀"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABYAAAATCAYAAACUef2IAAAABHNCSVQICAgIfAhkiAAAAWdJREFUOI3V1L9LV1EYBvDP19+TBIqoiIGrIqjQUDi6OAviXxAJhYkQgcHXRXARXSQIIWjKPQKdbQgciiRx0SAIJRycNBAdzrl0OdyvfkUdfOHy3vO+z3nuc577ckrlctldRE3u/TXO8bwCtgen+IrSdYi/xdxXAbuABryMAqom/h5zbwHuCcawhs2rSFPi3zgqIC5hUbDhVTWkKTFB9QN05WoTeIQl7Ofqk9jDCbYwfBlx5nOmugnzOIw5i3Esx9qAYM9ndF+mmP8/cAoP8QbHOdw03uMdfuIF/uDZVYr70CaM4A+s5jANGMJ6sncdjysRb+NMsGIOzVHdWQ7TilocJHsP0J4t6pLmCXbRj0F8wobiSGe5lK+ligl2NEbQTEH/bzxBe1JvkztFEfFE/Ho9dgr6/4TxGknqI/iSLVIrqo1FfBDujU08RSfe3pT4I1owiw5hckbx66bEsBKfwijy+Fbi/hFfADQbRZTpeVBbAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle v_{0}$"
      ],
      "text/plain": [
       "v₀"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABcAAAATCAYAAAB7u5a2AAAABHNCSVQICAgIfAhkiAAAAY1JREFUOI3V1D9IllEUBvDfV9oWmIVZ+A0VNDS0tAUOBQ61NBYNgpPU0OAWKHw0BC1BSwhCKCEk0hxIlFBBmUKCOLREEZYpNdQg/fsa7n3xensD/3wOPXC573M4PPec5xzeSq1Ws13YURK7iFG8xld8wUv0bFS8KeO7MYJpPMEntOEc7sTvG5sVr6OKj1m8X+ikZyvi3+LJ8QELaF2vMH97vgcDeC54/Uvopo6jeJ/lX8YbrGAGnf+q/DgmsB9TuIfP+IFD6MZskn8et+IDT3EJD3AM73Lxu2jBKUxmFV6L93QS68MwhiK/gjPxkaus2lKNlU+WCLdYXcOZeO/CidhpigmcLEghvhLvw2hOkvdiDB34iVcxvg87sZiJL6K9IIUtS3iE03iBhzgQ23yM35hPiihQz3gljaXbckHwvSr4dkTw9XrMS/1eFjap3Vq0pd2kA10SNqIMlYx/F/zvwngS78L9MvGN4qbQ6RSeoRcHMdgI8TFh4P3CfOZwFm8bIQ634ylF2S+3Yfh/xf8AxP1VACIxQPkAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle a_{0}$"
      ],
      "text/plain": [
       "a₀"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABcAAAATCAYAAAB7u5a2AAAABHNCSVQICAgIfAhkiAAAAVpJREFUOI3V1DFIHEEUxvGfciGCBxHTpQhXWGmCQU1jEWKhIhY2NhaCEEgVYhewu1Kw00pII2LKQBQUbRQUBBtRC0UbMWKXQDqbaIqZheW4O3Y9UvjB8u1j3/znzczbaSqXy/6XmiviftxjHhPYxR/c4gADjcB7og9iGb+xGCd5i3W8bBT+Au8xhi9xsgW04HOj8E/Yq/j2NXrnQ+BP48CfWKmS+yv6k+jvsIYb4ZzG68Ffx4GbuKsCL0W/it6KI2GVVVVIvSdbclkjdzT6VvSN+NRUuvIE3lYlrx0fcY0f9YC14L3Rx4UlJyriG55jWuj5TCqk/JWwh89wjFXhkMeE1pzB96zgdOVdQg/vYwjn+IBJnGIYs3nA6cqT/T7EBUbygrLCs6qIjlRcwhvhyriqhP/FSQ54H7ZT8Vz0JUwl8GZ040yOTsAOmuolFIS/sZgDmlmVF9fjgf8DAMQ5y53sY1YAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle p_{1}$"
      ],
      "text/plain": [
       "p₁"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABYAAAATCAYAAACUef2IAAAABHNCSVQICAgIfAhkiAAAASZJREFUOI3V1L8rRWEcx/HXlV9FMpkUyeYmSRblr7jL3WwWCinZrkVJyT9gsFolycBisRElkySDwWBiEMPz3Dod97jnugw+dfqe59u3d58+z49CpVLxF2pJ/K/iA/MZs0N4wzkKjYAvYi1mzG6gHYvRQG7wZawjNeamUMIezupB0+AHPNcAF7AlxLCSB5oGE1z3oj/RK2MS27iLvWns41GIpVQPXM256roT63iKtaquODuX5bi1hmPCBh5hAQOYxUti7jB+mcpyXESfcASvsPMdJA/4Gu9CFGvowVLsNaR0FK+4xSjGcYDjRqF8dUyIo0PY7eWfQLPAZeHstuHmp+B0FHnVjeHEehBjwgW7bwY8gZPEejPWXcw0Az5V54WrlfGv6P+BPwEuqTKQ872aywAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle v_{1}$"
      ],
      "text/plain": [
       "v₁"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABYAAAATCAYAAACUef2IAAAABHNCSVQICAgIfAhkiAAAAU9JREFUOI3V1L1LHFEUxuFng1YqrAkYBBf8CJZiYS2YziqNhViIlrbWCSwpAsH/QVlEiIWVhSCSLNhEXUEbC0sRFQUtkkLIx6aYuzjM7sisH0UOXM6cM2d+896Xy80Vi0XPES8a9KawgmP8wA32MNsMuCVRd6CECrZxiS68w2J4/vwQcBUFXCT670U7mH0o+GdYyTjHGV5mgVLvcSc+4LvI2z+iXVQxiNPY7CjWww+rmEhTPIRNvMYuvuAav9CHaRzG5ttCvYS1pOI4eBl5jKGcmPsYciXW2wirYdSsKATF5QbQvLujtp8GSgPfhtyP1tj7V1hFD37jICu4ZsUVvuItdrCFbozjG/7iKCYgs2KYFPlcwBwGMI9PYa5S93UGxTXV0ylzuWagSXCz0Y43sboXw6IjevIY8IjI/1oshFzCzGPAZfdY1OjafJL4/8D/AO4sQZgeq3dQAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle a_{1}$"
      ],
      "text/plain": [
       "a₁"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print(\"Boundary Values\")\n",
    "p0, v0, a0 = sp.var('p_0, v_0, a_0')\n",
    "p1, v1, a1 = sp.var('p_1, v_1, a_1')\n",
    "display(p0, v0, a0, p1, v1, a1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Pontryagin minimum principle : \n"
     ]
    }
   ],
   "source": [
    "print(' Pontryagin minimum principle : ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "costate\n"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}\\operatorname{λ_{1}}{\\left(t \\right)}\\\\\\operatorname{λ_{2}}{\\left(t \\right)}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡λ₁(t)⎤\n",
       "⎢     ⎥\n",
       "⎣λ₂(t)⎦"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print('costate')\n",
    "λ1 = sp.Function('λ_1')(t) \n",
    "λ2 = sp.Function('λ_2')(t)\n",
    "λ = sp.Matrix([λ1, λ2])\n",
    "s = sp.Matrix([p, v])\n",
    "λ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hamiltonian function\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGg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qllDGUlyT55bTMCnY/50fLdwWJuIymLudA8c5mKDvI0oTlnX7R2cQHad19N8zk0SNEfUWoc5Q10knSrKW+hkroFdEdKLQa+NXW3o8g/kfgtt7Q34yyU4o0h/m1ehMxlswal2k203K6MkkffIvyTxq7sn1rGUFaS7JPHNseh3UdnUyLI/3+LQHP+aegtmjXluwo5YyjwZl5B0PHpsaSfcmxLMpdBrfoWpWsT8btFAe3NP1lx7c9pps96qlsErwoXwaUz2iVYi1abq6UL8CVKxUbnFYLqj09D25G5LGrRt0hd04JLe/NPVlz78xO0fR3NdHLRoaGhIW8fO9AKeCe0PfV3lfcdgRSaiU535mEOShPHoGPX3aj8ZkXc3LAtyFwmtejrWtduaJpwAPq9j1XAH+j/sUS3Ptubf7Li2p/3Aw+6FBDcZC5tgaR57K20POXoaR0aiN+9mY/WJzz/M1z8WFRboC69iaeVWY73U7vC/0C3x+MpBB9cPB5PIfjg4vF4CuFf5YI+nfOa8SUAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle u{\\left(t \\right)} \\operatorname{λ_{2}}{\\left(t \\right)} + v{\\left(t \\right)} \\operatorname{λ_{1}}{\\left(t \\right)} + \\frac{u^{2}{\\left(t \\right)}}{T}$"
      ],
      "text/plain": [
       "                           2   \n",
       "                          u (t)\n",
       "u(t)⋅λ₂(t) + v(t)⋅λ₁(t) + ─────\n",
       "                            T  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print('Hamiltonian function')\n",
    "H = (1/T)*u**2+λ1*v+λ2*u\n",
    "H"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Theorem 1:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start 1. solution λ(t)...\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGQAAAAhCAYA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q7S2Ier1GHwOES1hVQ4/mx5DlSdtRQb5H0q5gHSFtxbp1YabIqE4RbojIjN4VVXa7chOSx2p8bV1wzKIraavFD8m3bcplic2OIc8n7RSxMLKZ1lAcLBbtIsq5rDJ3IBNwrogJ9+dk6SQ0Wo/0YKHw/7vnZOmu+alGH+lpwfNVtQLtmhtDPhIpb7uYoyyuFJ5lriSDrJRlZZE9cp+FvURtkmIQ7vFfV5VFGkdG4/ES4xVhHo7FEeJsLUV6VHKtOARdK3bkI7nvp4jd2uj4vcU5ok66FYeKBX6AiLkrcGmqWGaHZAnZH6/l5FcL/zhdcWra2x1CELJGuMMsFmKaIGKaqHy7cjrDxHHFfHzWCxt6g4+E275PEHGhKLpvxXh8myq25e7UO8Xh3UGiYDkTL+Bo4Y4GZnTfEcG6GejB8Xi0is4l4oBxjNoxI4tp4h+fiJcaNXB9IbtDat2BTEj0DsD2ylW91TBErOZ0RbcnvysVb7PxKa6qY4xBgsh5NgIy+G8Myd6BEL56AaYKdzFenL0s0fs0mdjC2SB7U9LOURwofxeHcJNEIMwfoxShHXcKV7FRICUkvQMZl5Nn70D2FQG6GWQQrrDedHth8pTF++iuc4wNitRllbkD6VKf726hAaSElLkDGYW31p9p/0+khJS5AxkgUtcd1He00EIdSAlJ70CmijrjIhFcf7XuDuRSHIPPZa4cW2gu8nVICxsYfXEf0kIv0CKkn6FFSD9Di5B+hn8BKdQfX7T0zS4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{d}{d t} \\operatorname{λ_{1}}{\\left(t \\right)} = 0$"
      ],
      "text/plain": [
       "d            \n",
       "──(λ₁(t)) = 0\n",
       "dt           "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJwAAAAhCAYAAAAs7MLmAAAABHNCSVQICAgIfAhkiAAABXNJREFUeJztm2uMXVMUgL872jCZNiT1oypqgnSk6bTTmSqhGaQPEX8Qj1Qo0UQj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CJKuCQlb4bWXKbQuq06DvOj0Dr5nDbZdeaD1eq3qMoi95dfDiXO3DzgKuQmelJK890lhQXuk/L2lvwPNCH+AHHWXlm9A0ntG2i7m8mlIPK+HBZkYXeoyiL3l0MLnglaTVyrhqkHniU/07pQcyJRVzkexXizJ6PjE4b42vYy7A5UrlD2+jWNmwWabsvxshQa2Sh9yQy13tagzsB2G7l34YcgXQSvoVOGmn3IMvBfOSiQBi9yKWBJVZ6H9CBxIk6gFsoTPeGQ4GzEYf624j2a5FS9e5C5nrPWf+noQk5pD0ZCfIuBTYD5yDT9vhA2U8Qp7QU7gcuRHZZOxPKrkAOkltJ9h2CdGg/7cDbRcg4mskjM9PzMWUy1Xtwhku6AzdPy50IHIFb1D6OtYj/sxjZKEzWJ+oa0RrgGyR84ko9orBevLEZJiCzkZmRGvV3VFA8U70HDS7pDtwU4FckbraH6ICgK1ciO9NNyJJgnusjyu9HQifbcb8I2Ag8FNPmWGQOMlOZ2WqV/o4yqEz1bsIi5g7cXCs/eAduNuKIlhqzMxQTiunTx5VdiEPrKbCZ9LrPTO9mhnO5A9dCujXc4zkAY3Aud+CagY8qJ5pnNGIMLngH7ljgLORMDgoGV4dssaeQ7ujH4/kXY3DmDtyZiHO4HDmy+Z3CHbgbgXOB75CAn8eTGjsO5/GUlXLch/N4IvEG56ko3uA8FcUbnKei/APKUJw6LLqRqwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{d}{d t} \\operatorname{λ_{2}}{\\left(t \\right)} = - \\operatorname{λ_{1}}{\\left(t \\right)}$"
      ],
      "text/plain": [
       "d                 \n",
       "──(λ₂(t)) = -λ₁(t)\n",
       "dt                "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print('Start 1. solution λ(t)...')\n",
    "eq = sp.Eq(sp.diff(λ, (t, 1)), -sp.diff(H, (s, 1)))\n",
    "l1 = sp.Eq(eq.args[0][0], eq.args[1][0])\n",
    "display(l1)\n",
    "a = sp.Symbol('a')\n",
    "l2 = sp.Eq(eq.args[0][1], eq.args[1][1])\n",
    "display(l2)\n",
    "# display(λ)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGIAAAAVCAYAAAC9gjt3AAAABHNCSVQICAgIfAhkiAAAA9pJREFUaIHt2WuIVVUUB/Df5BSFWZbQA7LG+dDbmaCCgqg0kiIqxwwiTLGiB4VMD4hKYSjQikIqoqAH2Yu+1BRmaUXTix7m0EQmPQQrIkvtMWUU2mQf1rnMvXfOOTN3PDcnuH84rHPPXnuvffZ/r8fZt6mrq0sDux67pTy7AjuwBUszdBooGGmLvAF3Y3d04syc/rNxP97Bb4LApwqeYy2YhMvRjfX4E/14F5cpflMdiAHcl/zeLNZgpNdVpYGaUwZ/Lbl+xmKchFUZE1mIdmzFdzhy9O9UCC7Eg9iIHnwrFmsWHsHZic6OguydL8jtxng8UNXejFuxDUtS+q8sV8zCB4lsz9G5ThCwHqeJl9+V+BLnYQX+KXt+C1bjAkHKcwXZ68BPeFt4RldVe7sg4tOUtgrkueqGRLbl6PTgK8XtsJ3FG1iukgT4AQ8l96dn9L0YTwsyf8cv+AjzM/T3xfTE3kCGzgmJ7B1m3rkesSiRrdhbhJ//M7Yn8u+UtglYhjUi323CASL0PJbc31nV5xzsgedzbB6fyDXDTS6LiBm4NLlvwlS8P9xgo0QnJtag34cXarTRjLnJ/cqU9h2YLDynHAuFh8w3lIgO/CHyaRZKRIzKIybgYfyKlzBHhKd6EnFYDfrL1E7EHTgWL0svPLZK9/iN+B77Vz3fE2fhFfyVYbNZrNs2rB1ugmlE3IVDMU+48xz5CXtn0VLHsWEBbsDnuCRDZz9cK8LNEdhHZf78uEp/hgjX3Tl2jxGE9QoyclFNxDRcKTzhCRydPM9L2GMZ1+BerMMZoiSvRhteFWXuajyb6G3HFBHSPqnq0yEWd0WO7REnaiqJGC9q7X5BBnwhPoqmilxRj+qoXjmiU5wMrBUkbMrQezKxPw1vVrXdlsjyZDsO54oKrT/H/ogTNZVELBEV0lwRF4my7DPBbovBkrZI1CNH3CTyQp84GdiSoTdZeMQqQ0mYaLB0Ld/Vp4ov+LywRA2JmkEiThFuvFzskHL0CSLa1IeIloLHWyR2cq+I5WnhqIRSom0VRzqlEncSnsEhotztK+szS3ynvJgzbk2JutRhLzyqMiSVoxQf21OMz0wuOCiRJ+Px5H4LbhzJRArCPEHCgPgeWJCi87XB+W0WIWY6PsTrOFgchfSIBV+nsjKaiffwY848akrUBBG343ARkjam6JR2Q1rCPk68fDlakwu+8d8SMSWR40TIS8NbBomAi3CPWPyrxXHE9YmcrTLGnyi8ZOkw86gpLEFT4/+ImrAYN4uNVmiYbvzXUBs6RKguPFfmnTU1MBRH1WvghkeMETSIGCP4F073473hf3fwAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle λ1 = \\frac{2 a}{T}$"
      ],
      "text/plain": [
       "     2⋅a\n",
       "λ1 = ───\n",
       "      T "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKsAAAAVCAYAAAA5KB4cAAAABHNCSVQICAgIfAhkiAAABoxJREFUaIHt2nuMH1UVB/DP0mKpBYuWiChgaYxFpKVpIWBCGotQIcZoKyZKSlseQRRoGkw0BkgqYAGjKWqIRkFpjQlqajEF5ZUCVR5Cl5YIFJWkBRPLS6ACoYKl/nHuZGdnZ+Y3s+yju9lv8svdnXvnnnPmnnvO99yZrhUrVhjDGEYC9im5dh724EWsqhgzErAGz2PScCsygvA1sfZnNxg7J409Z1A1yqHMEbfhe9gXy3FKxb1TcC7W4Sm8gZ34szBgOJ38WCzC1Xg9d30odb5YLOYZAzhnU/TXztmp7W4goxs340rs32HswdiNH6b/XxDPpunvfBhfMvGd6fcSVuIE3F4y7ov4MXbgbjyTlFqI63FaGrOngyGDgZX4T9Ivj6HUuc3CDzT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pkuLbk2lLhrDeWyG2DJnZmFGB7xRwLUntHSd8+4vlsK1wfh8+KwmxnjX6Niit6O+tVovJfLHgYUVU/Lrx/aolC8E3BhbaIivDFTkILGEjOukO8HZneYY6mOh8mIuvt+jrMgXqOrfJRYVZq9wa+2tTOzGGK3BsOEcHrH8qddboIZMVoP1cEjToKkJfdMbJmvOtEkSrWi0iSR6ZEGRW4TDyMbrFr2zoqsQm6WvyW1sy1BxtxED5SMaaNzllRME3wugxTxDnuoSJtbin0EW/QhhNt7Mwc5st6f0uxv6CDEwTnLaMIJ6S2yK0XinPe39fIbVxcZYMnivO0fPrPI+NjxxQELxFpcLc4e1xWcu92kcaGEmvxBXxavBfPo63OL4g0dpJ4rXiXiDSnicV5W/DAfKWbRYjviMr7dZGdfttvi9qjjZ0Zx94s3kRlNGuCcLgPiuxXdQw5P8kpOuXnxTnzczV6Ni6uJEWvEIe9i5Uf+VRF1iNSO04YU4Z7DY+zPifsKb6D7o/OX8L3hYN+VVT4F6f2dH251kZclPtNEGeTQ+msbezMHGYTvo0f6QlaD4jToHsq5pgsnPIW/DN3/TiRdVZ10LMxBaD+24CRjG8JB5lt7+COoxUXiS+p5ooInmGlWINpyuucfmGkfqvaCavEl0aXdxo4hn5jonDItXo7KnF68KgBdFTqvw0YydglDr7niYKhzavXMTTDVPxUOc372GAIHK3OSnDHjcOtxCjGVqwYSoGjlQaMYRTi/44/vqUM2KlhAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle λ2 = \\frac{2 a t + 2 b}{T}$"
      ],
      "text/plain": [
       "     2⋅a⋅t + 2⋅b\n",
       "λ2 = ───────────\n",
       "          T     "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# constant\n",
    "a, b = sp.var('a b')\n",
    "λ1, λ2 = sp.var('λ1 λ2')\n",
    "display(sp.Eq(λ1, 2 * a / T))\n",
    "display(sp.Eq(λ2, (2 * a * t + 2 * b) / T))\n",
    "λ1 = 2 * a / T\n",
    "λ2 = (2 * a * t + 2 * b) / T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Theorem 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIkAAAAVCAYAAABygM3xAAAABHNCSVQICAgIfAhkiAAABTBJREFUaIHt2mmsXVMUB/BfTW3VTNTUwRBDaVN95oixCD6YviCGtj4YooqIxBQvDcUnjUQkRLVE0pIaQkIRQ820WoqKiramoihV8VCeD+scPe/03HPPlXe8F3n/5Gbfe9bae6+1z/+stfY+t197e7s+9KEMG/S0ATncj28xqIU+bejEBbVY9P/GJWLtJpQp1UWSdkxvsc8BOAe34pcC+ZXCobNz1+fjMdyEzVqcsyfRyJ//EmOSdn6ZUneSZFiJbEiFuaZgNe5qIC9z6BbsgMuazNGbUOkG1Yw2dOCDMqXuIsmueB9TsWXm+gDckBhxWEn/PTEWD+HXBjptWIMlBbK38BEuxIatGN6DKPOnCsaJSHTUv+zfH/viPawtU8yT5Npk4tMKdIclskcKZEuxDzbHhzgWowRx9sdBeKXEjgnoh1kFstuSefcW6eTP5HenSE8pZmKoIFtP4Gw8iI/xM1bhbYzP6VX1p26MxMYiko3GbHwvUv0z2C9V3CjXsSwEHpC0CxpM+oUoHk8XEWFDTMIdFQweKxbrjQLZfMzA+XgNz2ZkL2W+v5q0x2FOhTm7E5sLG+fhZVF8b49TMC35fluiW9WfutGWtMPE2j2Fe3GoWMPnRYT/MU+SNnyHzwoGbUaSXUTBeiJeFzuUSTgS14l0UIRBgsmLFResD2ErsajTcU+Dcd5O2iMayFNcnoxXFQtFYVyGTlF3fZ27fr2ILOOtI0lVf+pGSpKDcbiu9/V+nCt2P1OyJNkGwzV+ClOSvFMg21XktmkYgSuSsS7C1aJmOElxytlZRJ0Vjf35J8I1Iij8JIqwoSU6BEnKiuw8ZmhOkjXJJ48V+EqsbRZV/KkbqQ1XF9hxpyDJSLqmm7TTvJJBvxVO57FU5LDluesdmIz78GWDcbdN2lUN5Oncf2BRiQ78gMFNdIY3kf8bbI1LcTL2wha61nv5m1DVnxTLNCb2CwXXZojCthE2FgRYLqJGHmlEHEBXkqThp6ge2U08DU+XTJwnSBafl8jS3cyABvKNhEMf4reScWCgxrujujBKFHqDRcScKcj6h4iw5+HdjH4r/qSYav0UOVrUPDMEibJY2GS8kdgETyje2aSEXJ4anGL/pC1KJyclbdXw2F5Rj4hOrIsoeYwQBCqyK4sNxEIubaLX3TXJA8l4R+PFnGxy0majc1V/sphacG2cIMn0gnmbIc0ayxrI093tM3Qlyd6C/fmI0F+cP9CaY1WxAitFmC7C6KRtRtC9xDa62VPUnTXJEBFJ5lj/Rm1l3fY3G52r+lMn0qyRr5VgR3G/l0hIks2bv4tctWfm2iBRjKZ75joc68RcbIc9CuRphFndZJxDkrYoR2cxXJCp6mdcyVgdSbubWLuszbPEjm+trsSt6k+dSElylq7vyTYTNUp/cXq9lq6RZA4OFHv1R5MOx4pdywpsik9rMno2zsAJ+CQnS5/CmwVZfxEnuA/n9I4XZy2P12RjEVaK84Rj8CaeE0/iiYKsf4naoyPTp6o/dSGtiRaIe5qm0/7ijGsnEW3/qT+zkeRmcfDVKZ6eESKnniXeiyxMZHVgNr4RRV4eczFRLOZE3GhdyE6xJU7Fk8qL5DpwpqhLhuBi7C5e3k0R65vfLVbxp07sK2qieSIILBLpZZwg6zFyB6D9etH/Sa4RCztG62ltonDsCHHi2YduRG/6P8nt4qR3cjPFHAYKgs3WR5Ba0JtI0iFO+eZp7U9Hw3E3rqrBpj5Y/wVfT2Nu8mkFi7V2LtOHFtGbIkkfein+BuEkKRchiHR+AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\operatorname{u*}{\\left(t \\right)} = a t + b$"
      ],
      "text/plain": [
       "u*(t) = a⋅t + b"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0K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8FLzueMswXO+aPCuqvFIq0QVikTioSVWU6W9/3L4eLGGqoiOvSLmAr5dUsu4UhOQbvyak/TuYlgaxl2iPSuVOEWV6jXMr1QFgpTuTnqD2YrOzqnxPWcpdQ+B9k2s0WCl+0sNrBo8LFmiVe2bld7LBnCaV+Tvj66Sxb2fGUYa44e/lnTt1C4WbuE2dfea9abdP8O5T9pRL7bMQLVd3noWJTOEZ4Ddl0fSvl1R+uwI9FLLwwefZIYTHHiPn+H3mvE20Wg9yPT7azpwkrxYJYkFO3TryRsSspr1I1/RVGiIX1E/WTHe3gfSJuGiPS2a8UlnypkO36TPsy4ynDa4TlK3LxxiflYLFIr8r56+nHc/vLJBGDrBdW8m7h1vWIBTpL/gF/q+TVX9aIhNwt4mD5EhGnPiVHNwYNkP+0XSwW4Cma948vFBMxXezCzweWCplN0Djp0uUgMVD+n+ka/E01A1aWw8SiWun5o0hE5muzriINKLIxU6fYIw4SZ4rgNO/VojzG4ZsOnu8/UDih0x3oUstAUSbCP17XsFVf7tPcuVaXLm1joLh5Xbr839NVpi5dWsR/AYbA2vV3tf0yAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\operatorname{v*}{\\left(t \\right)} = \\frac{a t^{2}}{2} + b t + c$"
      ],
      "text/plain": [
       "           2          \n",
       "        a⋅t           \n",
       "v*(t) = ──── + b⋅t + c\n",
       "         2            "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADoAAAATCAYAAADBGB7WAAAABHNCSVQICAgIfAhkiAAAAkRJREFUWIXt119ojlEcB/DPi2YXksKa5c9y4caSUQopNyNKuRDNDXeiMEttKxdzo5QWN1JS5MZISa2FCxfajShb240b1ErTQiKzGi7O89izZ+/77tm8LV6+dTqd3/l1zvf3nN+/J9fe3u5fwJwC8u3oxCC+4S0eYO/s0NKGHzheYH91xOspclkOnJdHdhEnMYwuwchV2IEtuDctyjNDbzTXFdg/jwqcEj7IlEgbek4w8i4O4UtibwEWFzinCYuyXBjhheIfrC+a1+bZ24p9uI2erBcmDa1HC57hIEZTup+jkQ9NwqtnxQ3FDR3Ee5MNzaFDcNuWadw3IUabo3WryUZOhdqIRNZxOMOZfYKXLE/IGrFJCK/XKf1jeIURPMe25GbS0J34gMcZSMwG4jiNX7VSCK130ZzEAVyK5PWCS3djZawQu24llgqx830GpEodo4zHaZ2Q8ePwOIJPKd1mXMfVaH0Cu3BUyOC/DI1TdNU0yCZR6hhlYuatEgj341pKrwIbcSElfyhUCYy77tfokBrsz3PpGswtQqpW6WN0AGOC657FQuHlxlJ6SyJuQyn5EKrjRTLrtuI+bgmlZUBwx/VYgWUZyJUSI3iJddgg1PRHRfTT9TSXlCWTUZfQEXVjs1CM9+AjTv8m6ZmiF/MFwoU4DAuvXJ2SV0m8crpheBKNPwWN0SiGUaGcNOBOQt4gND7I3wL+jejATaH37REycw2uxArlYmin0J6eEXJJP3bjTaxQLobC5WjkRaHftLLDf0PLDT8B9M9wl9JabqIAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle c = v_{0}$"
      ],
      "text/plain": [
       "c = v₀"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAR8AAAAaCAYAAACO7VhKAAAABHNCSVQICAgIfAhkiAAACq1JREFUeJztnHuUVVUdxz/AIBAoKgWoII8SRMUQBBULBQaIWCWQVFLAQA9NA5FaAmkKVoir1ZJYSS+zgR4LtUkLkSCzmh4U8hgTUMEVIBgPIUEkKET647u399xz93kN5869yPmsNWvPnH3O3b/9O3v/9u/32/tOo1mzZpGRkZHR0DQutQAZTm4B/gG8bn5WAiNKKlF5MxN4BunqVWAJcElJJcqIJDM+5ckOYAbQB7gceBp4HLi0lEKVMdcCC4D+wCDgTeAp4OwSypQRQbkZn0XAHqBlgmf6AMeBzxRFotLwK+BJYDOwCbgDOAhcVUqhUuRm9M4mpfR5w4AfA+u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dlSEVyPt5PzrJmfZOVlJqCT6kFMTzJDtXlJGRUQZUoB2Zk+k/AGZkZLwDOFn+PWRGRsY7jMz4ZGRklITM+GRkZJSE/wP54rZAu3UacAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\operatorname{p*}{\\left(t \\right)} = \\frac{a t^{3}}{6} + \\frac{b t^{2}}{2} + c t + d$"
      ],
      "text/plain": [
       "           3      2          \n",
       "        a⋅t    b⋅t           \n",
       "p*(t) = ──── + ──── + c⋅t + d\n",
       "         6      2            "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADwAAAAXCAYAAABXlyyHAAAABHNCSVQICAgIfAhkiAAAAsdJREFUWIXl2EtolFcUB/BfNLaCBcVKiIoa3PlCNNSFUlAwihXpRhAXUkFRKmpFpEUoIUFpXYioqPjowgeKRSzVhVLBhVERBGurgtIufIOBKriqtCS6OHfIl8ljZmQ6TPUPl/M9zr33/L97/+eemZqWlhbvEwaU6D8Wr/HTfxBLRVAq4enJ/lruQCqFtyV8o9yBVAqlEm5M9p1a4Vp8hVv4Gw/xNWrECj9Fe6UCxEyRN3ZjKS7jJV7hOuaUMlg+4Q9wDjvRgT24iFYcRL3Kr25ORk04hhc4IIh/kuIdW+xgtXn3e9PAzdgqviwcxqV03R/hDRhW7OT4DT8X8MkRHoXZuJJ5txvrsB6bipkwS3gGVqINW/L82nAXE/SfsDZgXDETJxxRPOG1upOFHwThicVOmN3S65Jt7sP3ebL9rXCD0HqxbXmB+D4UZB7jeD8xDco8W4P7QuM38Gm2Q5bwvDRAWx+TjxfJ6mmBIMuJKYLML+js5X1Dso+SXYJd+A7TcBXnZTSe29KDUYebunSbxUyhofMFAiy3hnPb+UEf7xcmeyHZjSLfHEr367EAX2IzXYQ7UqvrY+DWZAtl6HJrOEe4t484HKvwBGfECdOI7Xl+F8SCoWtL/4s/MRqL8jp8g7npulCF1aC8Gs4VOosxJPP8I5zAx6JmeIURGKhnjdAujlN0z9Lfiy9+GifxTBwDU0TSGKOyZ3AtJuN3DBWF0FmRyD4XEtus5w+ZfEnWZJ9lk9ZRsSWfiIrmC0F0VurwXFRdlcIkkVuuiYT6B1ZgmTgi52Nbxv8vIcv67sOok1n1/MJjV2r5KEWX5UJOvzeF3BYU8P9HSK4JpzLPm8SuRU/C1YQs4WKxQ5Sf18WRtFps/f05h2on3IHbJfT5USSybzESd/CZjBSrlfAATMU9kYFLwb7UekW1Eu4UR0/ZUeofAP97vHeE3wAl1I5SEvQq+wAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle d = p_{0}$"
      ],
      "text/plain": [
       "d = p₀"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "c, d = sp.var('c d')\n",
    "display(sp.Eq(u_best, a * t + b))\n",
    "display(sp.Eq(v_best, a * t**2 / 2 + b * t + c))\n",
    "display(sp.Eq(c, v0))\n",
    "display(sp.Eq(p_best, a * t**3 / 6 + b * t**2 / 2 + c*t + d))\n",
    "display(sp.Eq(d, p0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMkAAAAWCAYAAABqrrj/AAAABHNCSVQICAgIfAhkiAAABQ9JREFUeJzt23eIHVUUx/HPi1mNWNFoTBSNBUTXWGIDG7agUTAKAQn+4QZTjCUWBBVFo38oQggxICq2rFHBgg1sUVCwYVlSjCBqMFbsFU0UN/rHmWFfZt+8t7N5bzcT3hcel733zsxv5sy595w7dyvz5s3Tpk2bfEbUabsO/yW//YdGTmn4Qd+zGcjvwuGR2aYZjMypr+AC/IYdMBNXDZWoTZxtcEembqQYVP7BrTWOebHVotq0jkpOuHWaMOzNOAdjsbt4Cdr05xAsRw+OGGYtWbrwAE7Ca8OqpDhdNgHteeHWzKR8EN0YLZylFseIkGIRpuF1MQOtw7viBjd3UsfoyWm/Vj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fzD6Ucwu2ZF3V/1H6FaSDgBF7Ftm7YdiWa2TpeHWeYqFOxV9qwLLRK4yWYQQ24m8ZXN3ELhfPIvZA+w/LenfgY9y+vwjnG5Spn6SyAuLsji55msFj0tj+iL2LbP2CfoWVzYgbxdwUSFtmssCkf+9K77CzxYhwl1DqGGw9i2r9hEiFB6Hv8R3QWy8k/SKj2htmsujIrG8XoS2q3AGPh9CDYO1b1m1Xyf20F2CO3Fx2pC3Vb4RI8Ta/hr5m/balJcy27fp2gc7k6wXS2ltNk/KbN+ma6/377tt2rTRdpI2bRryP4Akmb8/JN3kAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle Δp = - T v_{0} + p_{0} + p_{t}$"
      ],
      "text/plain": [
       "Δp = -T⋅v₀ + p₀ + pₜ"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI0AAAAWCAYAAAD9/x8lAAAABHNCSVQICAgIfAhkiAAAA4pJREFUaIHt2kuIHFUUxvFfRyfoRlzExATB+ADRiRIjKqiRoCIq+EQQV04wTkhAiSKoRHRcKAgSxp2gYtrowhfqQsQoKPiARIJJjJtoTBQVI+ITTQJOdHGqnJqa6p6q0A96qD8Ul7739q3vdJ0+99zT3RgbG1NTU4U5bcbW49/kOqM3cmoGgVZO08Dt+D15fUdv5NQMAq2c5kqcgifxOW7D3F6JqmnJiIj8K/opopXTpJHleTQxDzcWzHtAGHFni3VOxSFsFdFrNjCoNndMd5HTLMB1+BB78CImMFowd0fSLmmx/uMiQt2dCJ4NDKrNHdN9dEHfSgyJCAM/YjOuwun4KjN3Z9IOF6xzMW7Gy/i4jYZ1OL6dyBzb8UaF+Z2mEzb3g47pzjtNA6twAK9k+pu4Ohm7P9P/HX4pENLABhHu7ptBwzqcPJPQnJZ+Ok0nbO4HHdOd354uw2l4HX9k+t/EbyIRG8q9Z6eIFCdl+m7FBRjHvhk0LE6El71GZlgvzz6TpYMy1wsl1qxq81rsxUFsw/Ij1P1cMvZ+wdjGLuh+Am/lF8lHmjRvaeb6D4rQNYrr8WpmbIfI5oeFNx+Dx/BT0vabPUJ/WX4oMaeKzbeIU+hafIQ1eBtn4ds29xg3fdteKj7/pukPeHuHdcP5+CDfmXWaE3ADvsd7BQs0hdOMmuo06V65BO+Y3G5WmxqtWtHtnObyCnPLUsXme0QUeDp5fZfY6teIE00rxgv6RoTTbFTwMEtQVvcQ/kraS/EQduFspjpNWovZhMMFN/wEX+IKUcPZm/Rns/L54oPYhWdLGjJoOQ3lbZ6L80SYz7IZF3VTYAvK6p7AJdiCC0VEPJQOZnOaVUmb35qybDKZLKd8kdxkGI/gOPHtmihpyGLdzWm6QVmb5+Eo7M/178eJXdZYRFndh7EIf+JTcYL+NR1MI80K8fvSAdzb5qYLknYlHsY/Il/YjXOwTCRO7x6RSYNDVZvzdY9GQV8vqKL7XBGZpulMnSatAB8rfnOaiYW4VpyyJIufKZyondPNJsrY/LP4FuejynzTo0+vKPusluKzooFG/deIrrNFPKhsRX03XtM+Ee43X4sT1TP5gaKKcE1n2SBywa2i2rpa5AtP9VNUCeaIbWwR/hZ1uv8HarrLS+KE+KAoFyzHNfimn6JKsB43iXrOo9mBenuqqUwdaWoqUztNTWVqp6mpzH/QoAOTtetgFQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle Δv = - v_{0} + v_{t}$"
      ],
      "text/plain": [
       "Δv = -v₀ + vₜ"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "v0, vt = sp.var('v_0 v_t')\n",
    "p0, pt = sp.var('p_0, p_t')\n",
    "T = sp.var('T')\n",
    "\n",
    "dp = sp.Symbol('Δp')\n",
    "display(sp.Eq(dp, (pt-v0*T+p0)))\n",
    "dp = pt-v0*T+p0\n",
    "\n",
    "dv = sp.Symbol('Δv')\n",
    "display(sp.Eq(dv, (-v0+vt)))\n",
    "dv = vt - v0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}- \\frac{12}{T^{3}} & \\frac{6}{T^{2}}\\\\\\frac{6}{T^{2}} & - \\frac{2}{T}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡-12   6  ⎤\n",
       "⎢────  ── ⎥\n",
       "⎢  3    2 ⎥\n",
       "⎢ T    T  ⎥\n",
       "⎢         ⎥\n",
       "⎢ 6    -2 ⎥\n",
       "⎢ ──   ───⎥\n",
       "⎢  2    T ⎥\n",
       "⎣ T       ⎦"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}- T v_{0} + p_{0} + p_{t}\\\\- v_{0} + v_{t}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡-T⋅v₀ + p₀ + pₜ⎤\n",
       "⎢               ⎥\n",
       "⎣   -v₀ + vₜ    ⎦"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}- \\frac{12}{T^{3}} & \\frac{6}{T^{2}}\\\\\\frac{6}{T^{2}} & - \\frac{2}{T}\\end{matrix}\\right] \\left[\\begin{matrix}- T v_{0} + p_{0} + p_{t}\\\\- v_{0} + v_{t}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡-12   6  ⎤                  \n",
       "⎢────  ── ⎥                  \n",
       "⎢  3    2 ⎥                  \n",
       "⎢ T    T  ⎥ ⎡-T⋅v₀ + p₀ + pₜ⎤\n",
       "⎢         ⎥⋅⎢               ⎥\n",
       "⎢ 6    -2 ⎥ ⎣   -v₀ + vₜ    ⎦\n",
       "⎢ ──   ───⎥                  \n",
       "⎢  2    T ⎥                  \n",
       "⎣ T       ⎦                  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhE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GO7un7TZR5PT7BPVtF5S0WK7MIqP58oeLpxzQLjYayVDmRRNzh5OVFP3JRXzRYIg8ZzGapG0mJgEaUaZHVS9pGIBbhTRzDkiPPytadI1a0iGMjuoeknFA9nxxBRIrtfsoOolFYkekAxldjCic9ZEYgokQ5n5dHpJRaIHJEOZ+XR6SUWiByRDmfnUeUlFYookQ5n5bBYZ3unRhD6SDCWRqEEylESiBslQEoka/A+iou8mbSq4vwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle a = \\frac{6 \\left(T v_{0} + T v_{t} - 2 p_{0} - 2 p_{t}\\right)}{T^{3}}$"
      ],
      "text/plain": [
       "    6⋅(T⋅v₀ + T⋅vₜ - 2⋅p₀ - 2⋅pₜ)\n",
       "a = ─────────────────────────────\n",
       "                   3             \n",
       "                  T              "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQoAAAAlCAYAAAC6RqeeAAAABHNCSVQICAgIfAhkiAAAB4JJREFUeJzt3HusXFUVx/HPxWILgigFQmuJVWMM4pV6W4kIYlEeKkYrxkcREg0aYkWtjRoFjNU/BKJNFHkFXxWfUSI+ooKxJEZ8RQql1xIRHyAWi7QQi1gs1frHmsk997BnzsydM3dmmv1NJufOPnvO/t01e9ZZe+199tjatWtlMplMO/YbtICaeCrux7MGLWQE2BdsdR3WDFrEPkhLuw67o/gwfoudeAA/wPMS9S7ADfjTDNt5FzY32tmJX+GMwvnTsLfitXKGbddBN/p6tdUw8HFchEP6cO2qvjAM9EtjS7sOu6NYjivxYrwMe/BTHFqocyDegc/30M7f8CEsxTLchO/i+Y3zP8eCwus+rCuVXddD++1Yj7UVdTrVV4ethoHN+AvO7rD+etU2bFLVF/rJep3p7JfGlnYddkdxOr6E32ES5+BwnFCocwb+h5t7aOd7+BHuwh9wIR7G8Y3zu7Ct8XoMC/GLQtk2bMX5pese06h/bA/aOqETfY9J2+ofBqe7l/a/j7P6oKe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MeJqd7ZsFevGpu6OrbrWOlZj2ViJeRVuAYfEZ5qnpiXXyPWNAwbp4s70dGmJzqHiTn4vRhCbRdDu1PU34mq6NZWg9Z9PD6AMwtl5+M1YkXqbHOFyKm8scX5QduLao10addyRLG0cXy6cAx78QXhkU4VK8CeMgPh/eZGkUxbNGghbdiD94k7wKRwxrPtJOjeVoPWfYfoj5OmQurdePcsaiiyRETcrRi0vajWSJd2LUcU14glvjuEY7itcO5asTLyQpFwSrFad45kk1h6msmMAmNiaHe2WME4jPRFYzmZ2Zzx+KDpToIIZ84x5X1SrBZeqlO+LDuKzOiwF08etIgK+qKx6Cj2F07gHhE9lNnWOLZb/rm4HlmZTGaYKOYoxvFE8Sh3asajGSnc029RmUxmuChGFM1hx90t6r6ucfxJm+vVmaOoe+45k8nMkKKjaM54HJqotwDnibnZKkdRV44itdAnM3ocha/gCPHo+MfwnYEqynRNylGsFLMajzTeHyRyFnPFEtB2C7EW16wvM/rswXvFI+NHiHUFN4hnDjIjwpzCcVzMdBxoakgwVyzIWCiihX4smc3s2zRX0xKrAh8SS8hTD4hlhpRmMvMYMZtxC14uFmGcJx4g2iK2obss8flMphuWidm1e6sqZoaLZkRxu+k5gTMTdTOZMqeJlZ7tOEs87jxfDGHPlRPVI0fq6dFMplOam/o22SicwqcKZTvEEPZ68YRoanvBzJCTHUWmF3aZ2hFpvumb+jYZE3sg3CRmPzIjyChthZcZblpteHSC2HhohUiSb9L+MYDMEJIjikxdtNrU92b5hjTy5C8wUxftNvXNjDjZUWTqYsLw7LOaqZnsKDJ1ULWpb2bEyY4iUwdVm/pmRpzsKDJ1ULWpb2bEyY4iUwfrxPYCecXlPkp2FJlMppLsKDKZTCXZUWQymUr+DyB4hGuJTdKQAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle b = \\frac{2 \\left(- 3 T v_{0} + T \\left(v_{0} - v_{t}\\right) + 3 p_{0} + 3 p_{t}\\right)}{T^{2}}$"
      ],
      "text/plain": [
       "    2⋅(-3⋅T⋅v₀ + T⋅(v₀ - vₜ) + 3⋅p₀ + 3⋅pₜ)\n",
       "b = ───────────────────────────────────────\n",
       "                        2                  \n",
       "                       T                   "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m1 = sp.Matrix([[-12, 6*T], [6*T, -2*T*T]]) / T**3\n",
    "m2 = sp.Matrix([dp, dv])\n",
    "display(m1)\n",
    "display(m2)\n",
    "a, b = m1 * m2\n",
    "d = sp.MatMul(m1, m2)\n",
    "display(d)\n",
    "display(sp.Eq(sp.Symbol('a'), sp.simplify(a)))\n",
    "display(sp.Eq(sp.Symbol('b'), sp.simplify(b)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Solve Cost FUnction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAioAAAApCAYAAAAbOwI0AAAABHNCSVQICAgIfAhkiAAACnRJREFUeJztnX2MHlUVh59tC1arFikSWjHWRmlQGusWkUYBNdgimtho1BQUY5REEImSaBQwWYwpkGAaBZRoCPUDUNBAwY+YYKMpxS8WSxcqCIFaqW2oLbaIFUTxjzND552dmXtn7ny9u78nefPuzsyZ9/zuuXfmzL13ZkbGxsYQQgghhOgjM1r6nVcCvwK2AvcC72vJti764EPbhGqejmUmhOgvOiZ1T6UYjFTsUZkJ/LfE9vOBIzHHjgTGgcXAvxq2rYs++NA2oZqnY5kJIfqLjkndUxSD3LyiSo/KC4FVJW12Ro4BPA48ARzRgm1d9MGHtgnVPB3LTAjRX3RM6p6iGHyInJwkL1G5EHgOuCpj3QXAz6O/V0TbFX1Wp+yPBw4B/lqkJocQ2zzKamjCh7ZpW3NTZfYpYAuwP/r8Bnh3tK5K3RxGpmsZFOkGaZ9K2l16q9DUMWk+8B1gN3AAmABOqfk3uqCNGGwAzsvacFbGshOBsyOn0hwT2cRdZRuxwMSMAzcCVySW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0XQZ9rsM+2sv6P1ViXiVuXcXaR08fziOhba2puNWBj2/gPi98BLu7+NrkwrLv+rmKyRNdmyYrw+xTo3fxLPBZ7HatCeCb+Pu/FXhVZNfULdlN0HRPUF0sxf1UxZD4hdi2RdNl0Oc67KO9rP9TJeZV4tZVrH309OE8EtrWmopbHfj45nNeOAmb0zJAlbcnfxrr2tld1rAiw3CFIgbp81V0zAjWhflh4LaOfemK6VwG01X7VNPtq6fr80houfc5br6+uc4Lx2LDldenV5SZoxJzNTaB5nbXhjWRzDBnYDO3laT0m2RWfwb5z73pkueAl3btRMdM5zKYrtqnmm5fPV2fR0LLvc9x8/XNdV5YTEaSAtV6VIQQQgghWqHsHBUhhBBCiNZQoiKEEEKI3qJERQghhBC9JZ5M2/fbSIUQQggxDYkTlazH9gohRAh3YU+ynom9CO3L3bojhBhGqtyeLIQQPpyGvctjJvZY7NuAzZ16JIQYOjRHRQjRFPELxw6NPkIIURolKkKIsqzA5rUVfVZH2/4OeynZHag3RQhRAQ39CCHKshGYn/h/HLgRuCKxbE/0/WbsqZU3A8cB97XhoBBi6qBERQhRlgPRB2AesADYhL1wLIv9wAZszooSFSFEKTT0I4QIYTT6Hk8tn4u99h1gNjZc9EBbTgkhpg7qURFChLAMG+bZnlr+MuDHwCHYBdFNwE/adU0IMRVQoiKECGEUuCdj+TYsiRFCiCA09COECGGUycM+QghRG0pUhBBVmQssIrtHRQghakGJihCiKqPY6zeUqAghGkOJihCiKqPAPuCRrh0RQkxdlKgIIaryVeAw9PZ1IUSDKFERQgghRG9RoiKEEEKI3qJERQghhBC9RYmKEEIIIXrL/wHMUwBzq+suxQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{4 \\left(T^{2} v_{0}^{2} + T^{2} v_{0} v_{t} + T^{2} v_{t}^{2} - 3 T p_{0} v_{0} - 3 T p_{0} v_{t} - 3 T p_{t} v_{0} - 3 T p_{t} v_{t} + 3 p_{0}^{2} + 6 p_{0} p_{t} + 3 p_{t}^{2}\\right)}{T^{3}}$"
      ],
      "text/plain": [
       "  ⎛ 2   2    2          2   2                                                 \n",
       "4⋅⎝T ⋅v₀  + T ⋅v₀⋅vₜ + T ⋅vₜ  - 3⋅T⋅p₀⋅v₀ - 3⋅T⋅p₀⋅vₜ - 3⋅T⋅pₜ⋅v₀ - 3⋅T⋅pₜ⋅vₜ \n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "                                                    3                         \n",
       "                                                   T                          \n",
       "\n",
       "      2                 2⎞\n",
       "+ 3⋅p₀  + 6⋅p₀⋅pₜ + 3⋅pₜ ⎠\n",
       "──────────────────────────\n",
       "                          \n",
       "                          "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "J = a*a*T**3/3 + a*b*T**2 + b*b*T\n",
    "display(sp.simplify(J))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Derivation for Cost Function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAnoAAAApCAYAAACiL4R8AAAABHNCSVQICAgIfAhkiAAACtNJREFUeJztnXuMHlUZh5/dVm2itcRCQwvqSrxEhbhukdCgUExpBU3cqKAFvJBKYoEQNUJUMK4mlhJsqtwkGKV4wWsCaJQ/tAQCRVRaoFuqgGAtFAhtQQpYRaT+8c6ks7PfN+d8c+b2zfd7ksnuzsyZPe9tznsuMzM0MTGBEEIIIYRoH8M1///XArcAW4F7gQ9VVLZK+qWeVTMIthdCiKai+2h7yLTlUM0jevOBeVjF5gEbgbcA/yq5bJX0Sz2rZhBsL4QQTUX30faQacu6R/QexyoG8CTwNHBgBWWrpF/qWTWDYHshhGgquo+2h0xbFpHofRnYB1ye2Lc02pe1LU9d50jgZcAjOeoQUtaXIuSsop5Vk9ZLW2z/JeDPwB5gJ/Br4PCM84uKg35DespG+umOdNOZs4HNmF72AH8A3p86Zz5wLaa3vc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BCiJaiRE8IIYQQoqX8H9t5st+d8uhmAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{- 4 T^{2} v_{0}^{2} - 4 T^{2} v_{0} v_{t} - 4 T^{2} v_{t}^{2} + 24 T p_{0} v_{0} + 24 T p_{0} v_{t} + 24 T p_{t} v_{0} + 24 T p_{t} v_{t} - 36 p_{0}^{2} - 72 p_{0} p_{t} - 36 p_{t}^{2}}{T^{4}}$"
      ],
      "text/plain": [
       "     2   2      2            2   2                                            \n",
       "- 4⋅T ⋅v₀  - 4⋅T ⋅v₀⋅vₜ - 4⋅T ⋅vₜ  + 24⋅T⋅p₀⋅v₀ + 24⋅T⋅p₀⋅vₜ + 24⋅T⋅pₜ⋅v₀ + 24\n",
       "──────────────────────────────────────────────────────────────────────────────\n",
       "                                                          4                   \n",
       "                                                         T                    \n",
       "\n",
       "                2                   2\n",
       "⋅T⋅pₜ⋅vₜ - 36⋅p₀  - 72⋅p₀⋅pₜ - 36⋅pₜ \n",
       "─────────────────────────────────────\n",
       "                                     \n",
       "                                     "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dJ = sp.diff(J, (T, 1))\n",
    "display(sp.simplify(dJ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKcAAAAaCAYAAADSQkxHAAAABHNCSVQICAgIfAhkiAAABHpJREFUeJzt21+IVGUYx/HPWpCQUfQPCyIvokIyNvWiP2BbQRIRSVCR/VEoCROppEgLaotaChGWCIm6SKOgPwpWiERW2kUFallpEHYhFXRRWJoSmmYXzzk6Ozuz58zs2TPT7HxhOJ73nPPO89v3Oc/7vO8z9vT39+vSpR2Z0GoDKngcR/FSqw0pkUX4FvuSzxe4saUWlccybBG6f8MHuKTyhnZxzsuxQAzUeOIXLMUMzMQnWIdLW2lUSfRhJa7EtTiMjTg9veHElpg1lFPxJu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jPKX8IfVX+13umsEJvINasb44yNYofgviI7bYffc/4fGbHsNg4Zk5JrM845SfzMLWWKCNl78FMBNrU7mWW3Dqe0kmszzjnT0M3a5ckxqwrRKWSW3Tqc0kquzTjnJjlKTx3MeNZOiQGoXf6DW5cuw+g6Z5e2peucXdqW/wBvwmgyLcdW6wAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle c_{1} t^{4} + c_{2} t^{3} + c_{3} t^{2}$"
      ],
      "text/plain": [
       "    4       3       2\n",
       "c₁⋅t  + c₂⋅t  + c₃⋅t "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAn0AAAAcCAYAAAAURAkbAAAABHNCSVQICAgIfAhkiAAADpdJREFUeJztnXu0FVUdxz/3Cj6WIpWGRGpGmSZhCGqmiddQLFvle5mpdVHxgUmklpFkN9OClQ+gfJSlmPYQs7LS1MQHmgY+AkNLLL0+SkFQUQk0Hv3xne2ZO3f2mTlz9syZc+7+rHXXwLzOb37z27/57b1/e++2rq4uPB6Px+PxeDytTXujBSiArwPrgR80WpAWZTLwAPAq8CLwe+BDDZXIzqnAI0jWV4H7gU81VCKPx5M3zeSjmklWT/HUbR+tHvTtAYxHH3pPPnQAlwJ7Ah8H1gC3A+9ooEw2ngO+BowCdgXuAH4L7NxIoTweT650kN1HHZCfWLF00Dz+1FM8HaSzj32AjeJu0MpB30DgZ8DxwMsJ5/4UWApsmrdQTcgo1FJ6vOX4AcBVwCLgb8CxwDuBvQqRrjZuBG4GngAWA2cDrwEftZzv7SKeJJsI43XY2tRiC40iq4/6bM5yxdFM/tRTPGntYyFwftwNXAd904A5wLPAKuAl4K/AN4EtEq7dG7gBeB54I9jeBhxoOf905Gw+Zzn+I+BXqDWnGrsCxwBTgZUJ5/ZFHkKtYecBm6U4fwCyq5fyFKoKSXZh2AA4Cj3TfTHHvV3YSWsTNh1uAZwA/Ab4J/IVK4B7UfCQ1i8di971+u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8fTB/BBn8fj8Xg8Hk8fwAd9Ho/H4/F4PH2A/wNhyHm9Q/KVFgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle - 36 t^{4} \\left(p_{0} - p_{t}\\right)^{2} + t^{3} \\left(p_{0} + p_{t}\\right) \\left(24 v_{0} + 24 v_{t}\\right) + t^{2} \\left(4 v_{0}^{2} + 4 v_{0} v_{t} + 4 v_{t}^{2}\\right)$"
      ],
      "text/plain": [
       "      4          2    3                              2 ⎛    2                 \n",
       "- 36⋅t ⋅(p₀ - pₜ)  + t ⋅(p₀ + pₜ)⋅(24⋅v₀ + 24⋅vₜ) + t ⋅⎝4⋅v₀  + 4⋅v₀⋅vₜ + 4⋅vₜ\n",
       "\n",
       "2⎞\n",
       " ⎠"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "c1, c2, c3, t = sp.var('c_1, c_2, c_3, t')\n",
    "f = sp.Function('f')(t)\n",
    "f = c1 * t**4 + c2 * t**3 + c3 * t**2\n",
    "display(f)\n",
    "c1 = -36 * (p0 - pt)**2\n",
    "c2 = 24 * (v0 + vt) * (p0 + pt)\n",
    "c3 = 4 * (v0*v0 + v0*vt + vt*vt)\n",
    "f = c1 * t**4 + c2 * t**3 + c3 * t**2\n",
    "display(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABTMAAAAwCAYAAADNYu7GAAAABHNCSVQICAgIfAhkiAAAHRVJREFUeJztnXmUJlV5h58BlBkQYdgOyyANKKPg6CDjgCJkZEcwoiZRUKERTSIiKnISBT02bsAxyKICQRI6LIpGRRYRkEUUFBARGEWRbdhBYJAZA4gg+eOtOl39fbXcqlvrV7/nnDrVXVW37vq99at7b713xsTEBEIIIYQQQgghhBBCCNF2Vko4fj/wNPB48P8vgI/XkiIhhBBCCCGEEEIIIUSf+TywS/D3bGBVYAtgWVJn5obAecDe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\\  \\left( - \\frac{\\sqrt{2 p_{0}^{2} v_{0}^{2} + 3 p_{0}^{2} v_{0} v_{t} + 2 p_{0}^{2} v_{t}^{2} + 2 p_{0} p_{t} v_{0} v_{t} + 2 p_{t}^{2} v_{0}^{2} + 3 p_{t}^{2} v_{0} v_{t} + 2 p_{t}^{2} v_{t}^{2}}}{3 \\left(- p_{0}^{2} + 2 p_{0} p_{t} - p_{t}^{2}\\right)} + \\frac{\\left(p_{0} + p_{t}\\right) \\left(v_{0} + v_{t}\\right)}{3 \\left(p_{0} - p_{t}\\right)^{2}}\\right), \\  \\left( \\frac{\\sqrt{2 p_{0}^{2} v_{0}^{2} + 3 p_{0}^{2} v_{0} v_{t} + 2 p_{0}^{2} v_{t}^{2} + 2 p_{0} p_{t} v_{0} v_{t} + 2 p_{t}^{2} v_{0}^{2} + 3 p_{t}^{2} v_{0} v_{t} + 2 p_{t}^{2} v_{t}^{2}}}{3 \\left(- p_{0}^{2} + 2 p_{0} p_{t} - p_{t}^{2}\\right)} + \\frac{\\left(p_{0} + p_{t}\\right) \\left(v_{0} + v_{t}\\right)}{3 \\left(p_{0} - p_{t}\\right)^{2}}\\right)\\right]$"
      ],
      "text/plain": [
       "⎡      ⎛     _________________________________________________________________\n",
       "⎢      ⎜    ╱     2   2       2             2   2                       2   2 \n",
       "⎢      ⎜  ╲╱  2⋅p₀ ⋅v₀  + 3⋅p₀ ⋅v₀⋅vₜ + 2⋅p₀ ⋅vₜ  + 2⋅p₀⋅pₜ⋅v₀⋅vₜ + 2⋅pₜ ⋅v₀  \n",
       "⎢(0,), ⎜- ────────────────────────────────────────────────────────────────────\n",
       "⎢      ⎜                                      ⎛    2               2⎞         \n",
       "⎣      ⎝                                    3⋅⎝- p₀  + 2⋅p₀⋅pₜ - pₜ ⎠         \n",
       "\n",
       "__________________________                       ⎞  ⎛   ______________________\n",
       "      2             2   2                        ⎟  ⎜  ╱     2   2       2    \n",
       "+ 3⋅pₜ ⋅v₀⋅vₜ + 2⋅pₜ ⋅vₜ     (p₀ + pₜ)⋅(v₀ + vₜ) ⎟  ⎜╲╱  2⋅p₀ ⋅v₀  + 3⋅p₀ ⋅v₀⋅\n",
       "────────────────────────── + ───────────────────,⎟, ⎜─────────────────────────\n",
       "                                            2    ⎟  ⎜                         \n",
       "                                 3⋅(p₀ - pₜ)     ⎠  ⎝                         \n",
       "\n",
       "_____________________________________________________________________         \n",
       "         2   2                       2   2       2             2   2          \n",
       "vₜ + 2⋅p₀ ⋅vₜ  + 2⋅p₀⋅pₜ⋅v₀⋅vₜ + 2⋅pₜ ⋅v₀  + 3⋅pₜ ⋅v₀⋅vₜ + 2⋅pₜ ⋅vₜ     (p₀ + \n",
       "───────────────────────────────────────────────────────────────────── + ──────\n",
       "           ⎛    2               2⎞                                            \n",
       "         3⋅⎝- p₀  + 2⋅p₀⋅pₜ - pₜ ⎠                                          3⋅\n",
       "\n",
       "              ⎞⎤\n",
       "              ⎟⎥\n",
       "pₜ)⋅(v₀ + vₜ) ⎟⎥\n",
       "─────────────,⎟⎥\n",
       "         2    ⎟⎥\n",
       "(p₀ - pₜ)     ⎠⎦"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "eq = sp.Eq(f, 0)\n",
    "display(sp.solve([eq], t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
